﻿using System.Text.Json.Nodes;
using Aop.Api.Util;
using Vin.Tool.Core.AssertCategory;

namespace Vin.Extension.Framework.Alipay.Service;

public class VinAlipayUserOrTokenCertificateService : VinAlipayBaseService
{
    /// <summary>
    /// 解密手机号
    /// </summary>
    public string PhoneNumber(string text)
    {
        EmptyTool.CheckIsNullOrEmpty(AlipayConfig.EncryptKey, "请配置支付宝解密密钥");
        var jsonRes = AlipayEncrypt.AesDencrypt(AlipayConfig.EncryptKey, text, "UTF-8");
        var obj = JsonNode.Parse(jsonRes)!;
        return obj["code"]!.ToString() == "10000" ? obj["mobile"]?.ToString() ?? "" : "";
    }
}